#include "GameCommandLog.h"

GameCommandLog::GameCommandLog()
{
}

GameCommandLog::~GameCommandLog()
{
	std::list<GameCommand*>::iterator it;

	for(it = commands.begin(); it != commands.end(); ++it)
	{
		delete (*it);
	}

	commands.clear();
}

void GameCommandLog::AddCommand(GameCommand* command)
{
	commands.push_back( command->Clone() );
}

bool GameCommandLog::Empty() const
{
	return commands.size() == 0;
}

void GameCommandLog::Execute()
{
	if (!Empty())
	{
		GameCommand *front = commands.front();

		front->Execute();
	}
}

void GameCommandLog::DropFront()
{
	if (!Empty())
	{
		GameCommand *front = commands.front();
		delete front;

		commands.pop_front();
	}
}


